﻿@using BaBaoFan.Modifier.Model
@model NavigationInfoCreateOrUpdateViewModel

@{
    ViewData["Title"] = "八宝饭数据修改器";
}
<div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>修改导航信息</legend>
        </fieldset>
        <form class="layui-form" action="UpdateNavigationInfo" method="post">
            <input asp-for="Id" hidden="hidden">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">网站名称</label>
                    <div class="layui-input-inline">
                        <input asp-for="Name" lay-verify="required" autocomplete="off" class="layui-input">
                        <span asp-validation-for="Name" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">Logo</label>
                    <div class="layui-input-inline">
                        <input asp-for="Logo" lay-verify="required" autocomplete="off" class="layui-input">
                        <span asp-validation-for="Logo" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">网站简介</label>
                <div class="layui-col-md4">
                    <textarea asp-for="Description" placeholder="请输入内容" class="layui-textarea"></textarea>
                    <span asp-validation-for="Description" class="text-danger"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">链接</label>
                <div class="layui-col-md4">
                    <input asp-for="Link" autocomplete="off" class="layui-input">
                    <span asp-validation-for="Link" class="text-danger"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">微信公众号</label>
                <div class="layui-col-md4">
                    <input asp-for="Weixin" autocomplete="off" class="layui-input">
                    <span asp-validation-for="Weixin" class="text-danger"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">所属父级</label>
                    <div class="layui-input-inline">
                        <select id="ParentId" name="ParentId" lay-verify="required" lay-search="" lay-filter="ParentId">
                            @foreach (var item in Model.AvaliableParents)
                            {
                                if (item.Value == Model.ParentId.ToString())
                                {
                                    <option value="@item.Value" selected="selected">@item.Text</option>
                                }
                                else
                                {
                                    <option value="@item.Value">@item.Text</option>
                                }
                            }
                        </select>
                        <span asp-validation-for="ParentId" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">显示状态</label>
                    <div class="layui-input-inline">
                        @Html.DropDownList("PlayState", Html.GetEnumSelectList<PlayState>())
                        <span asp-validation-for="PlayState" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">首页显示</label>
                    <div class="layui-input-inline">
                        @Html.DropDownList("HomeState", Html.GetEnumSelectList<HomeState>())
                        <span asp-validation-for="HomeState" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择所属栏目</label>
                <div class="layui-input-block">
                    @foreach (var item in Model.AvaliableNavigationColumns)
                    {
                        if (item.Selected)
                        {
                            <input type="checkbox" name="NavigationColumnIds" title="@item.Text" value="@item.Value" checked="checked">
                        }
                        else
                        {
                            <input type="checkbox" name="NavigationColumnIds" title="@item.Text" value="@item.Value">
                        }

                    }
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">审核</label>
                <div class="layui-input-block">
                    <input asp-for="Check" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" type="submit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
@section JavaScrpit{
    <script>
        layui.use('form', function () {

            var form = layui.form;

            var parentId = $("#ParentId").val();
            if (parentId != 0) { 
                hideDom();
            }

            form.on('select(ParentId)', function (data) {
                if (data.value != 0) {
                    hideDom();
                } else {
                    $(".layui-form-item").each(function () {
                        $(this).show();
                    });
                }
            });

            function hideDom() { 
                var index = 0;
                $(".layui-form-item").each(function () {
                    if (index == 1 || index == 2 || index == 6 || index == 7 || index == 8) {
                        $(this).hide();
                        $('form').find('div:hidden').find(':input').attr('disabled', 'disabled');
                    }
                    index++;
                });
            }
        });
    </script>
}